package main.inquiry;

import base.BaseCanvasWindow;

import dao.RenovateNoticeCanvasDao;
import model.RenovateNotice;

import java.awt.*;
import java.util.List;

public class RenovateNoticeCanvas extends BaseCanvasWindow {

    @Override
    protected String setCanvasTitle() {
        return "重修通知单";
    }

    @Override
    protected Canvas setCanvasContent() {
        return new RenovateNoticeArea();
    }

    class RenovateNoticeArea extends Canvas {
        public void paint(Graphics g) {
            g.setColor(Color.BLACK);
            g.drawString("以下为重修名单", 80, 20);
            g.drawString("学号", 10, 40);
            g.drawString("姓名", 80, 40);
            g.drawString("重修课程", 150, 40);

            try {
                List<RenovateNotice> list = RenovateNoticeCanvasDao.getRenovateNotices();
                int length = list.size();

                for (int i = 0; i < length; i++) {
                    RenovateNotice renovateNotice = list.get(i);
                    String sno = renovateNotice.getSno();
                    String sname = renovateNotice.getSname();
                    String cname = renovateNotice.getCname();

                    g.drawString(sno, 10, 60 + 20 * i);
                    g.drawString(sname, 80, 60 + 20 * i);
                    g.drawString(cname, 150, 60 + 20 * i);
                }

            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

}
